<%@page import="org.jeecgframework.web.util.StaticValue" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
    <div region="center" style="padding:1px;">
        <t:datagrid name="evaluateList" fitColumns="true" title="服务评价" pageList="[20,100,400]"
                    actionUrl="cbsInspectionEvaluateController.do?datagrid"
                    idField="id"
                    fit="true" queryMode="group" sortOrder="desc" sortName="cinemaName">
            <t:dgCol title="主键" field="id" hidden="true" width="120"/>
            <t:dgCol title="服务单主键" field="serviceId" hidden="true" width="120"/>
            <t:dgCol title="设备SN" field="sn" hidden="true" query="true" queryMode="single" width="120"/>
            <t:dgCol title="影院名称" field="cinemaName" query="true" queryMode="single" width="140" align="center"/>
            <t:dgCol title="联系人" field="contactName" queryMode="single" width="60" align="center"/>
            <t:dgCol title="电话" field="phone" queryMode="single" width="80" align="center"/>
            <t:dgCol title="创建时间" field="actualDate" formatter="yyyy-MM-dd" width="75" align="center" queryMode="group"
                     query="true"/>
            <t:dgCol title="服务类型" field="busType" dictionary="<%=StaticValue.DIC_EVALUATE_BUS_TYPE %>" width="60"
                      defaultSelectVal="<%=StaticValue.DIC_EVALUATE_BUS_TYPE_2 %>" align="center" query="true"/>
            <t:dgCol title="服务单/巡检ID" field="planId" query="true" queryMode="single" width="80"
                     url="cbsInspectionEvaluateController.do?detailsOfPlan&planId={planId}"
                     funname="planDetails"
                     align="center"/>
            <t:dgCol title="服务单位" field="departname" replace="华夏影联_77,中仪_07,时代_06,中巴服务_80,CGV服务_89,南方新干线_93,横店_04" width="130" sortable="false" query="true" align="center"/>
            <t:dgCol title="服务人" field="engineer" queryMode="single" width="55" sortable="false" align="center"/>
            <t:dgCol title="BP" field="bp" queryMode="single" width="70" sortable="false"  query="true" align="center"/>
            <t:dgCol title="级别" field="level" replace="P1_P1,P2_P3,P2_P3,P4_P4" queryMode="single" width="35" query="true" align="center"></t:dgCol>
            <t:dgCol title="是否发备件" field="part" replace="是_1,否_2" queryMode="single" width="50"  align="center"></t:dgCol>
            <t:dgCol title="是否关键备件" field="keypart" replace="是_1,否_2" queryMode="single" width="70" align="center"></t:dgCol>
            <%--<t:dgCol title="联系人"			field="inspection.zyCmIpCt.name"			width="120" />
            <t:dgCol title="联系电话"		field="inspection.zyCmIpCt.cellphone1"    dictionary="<%=StaticValue.DIC_TRUE_OR_FALSE_NUM %>" width="120" />
            --%>
            <t:dgCol title="评价状态" field="evaluateState" query="true" queryMode="single"
                     dictionary="<%=StaticValue.DIC_EVALUATE_STATE %>"
                     defaultSelectVal="<%=StaticValue.DIC_EVALUATE_STATE_0 %>" width="50" align="center"/>
            <t:dgCol title="评价人" field="evaluateName" queryMode="single" width="60" sortable="false" query="true"
                     align="center"/>
            <t:dgCol title="评价时间" field="evaluateTime" formatter="yyyy-MM-dd hh:mm" queryMode="group" query="true"
                     width="95" sortable="true"
                     align="center"/>
            <t:dgCol title="备注" field="remark" width="100" sortable="false" align="center"/>
            <t:dgCol title="操作" field="opt" width="60" align="center"/>
            <t:dgToolBar title="评价" icon="icon-add" funname="goEvaluate" width="900" height="600"/>
            <t:dgToolBar title="创建" icon="icon-add" funname="createEvaluate" width="900" height="600"/>
            <t:dgToolBar title="备注" icon="icon-edit" funname="goEditRemark"
                         url="cbsInspectionEvaluateController.do?goEditRemark" width="900" height="600"/>
            <t:dgToolBar title="导出" icon="icon-putout" funname="exportIe" url=""/>
            <t:dgFunOpt title="查看" funname="goView(id)" exp="evaluateState#eq#1"></t:dgFunOpt>
        </t:datagrid>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        //给时间控件加上样式
        $("#evaluateListtb").find("input[name='actualDate_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#evaluateListtb").find("input[name='actualDate_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#evaluateListtb").find("input[name='evaluateTime_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#evaluateListtb").find("input[name='evaluateTime_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        chooseBpForQueryParam("bp");
    });

    function createEvaluate() {
        $.dialog({
            content: 'url:inspectionWx.do?goCreateEvaluate',
            lock: true,
            width: 600,
            height: 540,
            title: '创建回访任务',
            opacity: 0.3,
            cache: false,
            ok: function () {
                iframe = this.iframe.contentWindow;
                iframe.$('#formobj').submit();
                return false;
            },
            cancelVal: '关闭',
            cancel: true /*为true等价于function(){}*/
        }).zindex();
    }

    function planDetails(fName, url) {
        var datas = $("#evaluateList").datagrid("getSelections");
        var serviceId = datas[0].serviceId;
        var busType = datas[0].busType;
        if (busType == '<%=StaticValue.DIC_EVALUATE_BUS_TYPE_1%>') {
            addOneTab("计划详情", url);
        } else {
            addOneTab("服务单详情", "cbsServiceController.do?detail&id=" + serviceId);
        }

    }

    function goView(id) {
        createdetailwindow('', 'inspectionWx.do?goPcEvaluateDetail&id=' + id, 900, 560);
    }

    function goEvaluate() {
        var datas = $("#evaluateList").datagrid("getSelections");
        if (datas.length != 1) {
            tip("请选择一项查看");
            return;
        }
        if (datas[0].evaluateState == '1') {
            tip("选择项已经评价过");
            return;
        }
        var id = datas[0].id;
        var busType = datas[0].busType;
        $.dialog({
            content: 'url:inspectionWx.do?goEvaluate&id=' + id + '&busType=' + busType,
            lock: true,
            //zIndex:1990,
            width: 900,
            height: 540,
            title: '评价修改',
            opacity: 0.3,
            cache: false,
            button: [{
                name: '暂存',
                callback: function () {
                    var iframe = this.iframe.contentWindow;
                    $(iframe.document).find("#evaluateState").val("0");
                    $('#btn_sub', iframe.document).click();
                    return true;
                }
            }],
            ok: function () {
                iframe = this.iframe.contentWindow;
                $(iframe.document).find("#evaluateState").val("1");
                saveObj();
                return false;
            },
            init: function () {
                top.myWindow = window;
            },
            cancelVal: '关闭',
            cancel: true /*为true等价于function(){}*/
        }).zindex();
//        createwindow('', 'inspectionWx.do?goEvaluate&id=' + id,900,540);
    }

    //备注
    function goEditRemark() {
        var datas = $("#evaluateList").datagrid("getSelections");
        if (datas.length != 1) {
            tip("请选择一项查看");
            return;
        }
        var id = datas[0].id;
        createwindow('备注', 'cbsInspectionEvaluateController.do?goEditRemark&id=' + id, 900, 600);
    }

    function importCinema() {
        createdetailwindow('基础数据导入', 'uploadCinemaController.do?uploadFile', 470, 150)
    }

    function exportIe() {
        var currPageRows = $("#evaluateList").datagrid("getRows");
        var idsData = [];
        $(currPageRows).each(function (i, rowData) {
            idsData.push(rowData.id);
        });
        if (idsData.length > 0) {
            myDownload("cbsInspectionEvaluateController.do?exportIe", "ids=" + idsData.join(","));
        } else {
            tip("当前页面没有数据可以导出");
        }
    }
</script>
